import java.util.Scanner;

/**
 * Created With IntelliJ IDEA
 * Description:牛客网:首页 > 试题广场 > 排序子序列
 * <a href="https://www.nowcoder.com/questionTerminal/2d3f6ddd82da445d804c95db22dcc471">...</a>
 * User: DELL
 * Data: 2023-03-24
 * Time: 23:12
 */
public class Solution {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int len = scanner.nextInt();
        //这里定义array的数组长度为len+1是为了后续操作中不会出现数组指针越界
        int[] array = new int[len+1];
        for (int i = 0; i < len; i++) {
            array[i] = scanner.nextInt();
        }
        int num = 0;
        int index = 0;
        while (index < len) {
            if (array[index] > array[index+1]) {
                while (index < len && array[index] > array[index+1]) {
                    index++;
                }
                num++;
                index++;
            } else if (array[index] == array[index+1]) {
                index++;
            } else {
                while (index < len && array[index] < array[index+1]) {
                    index++;
                }
                num++;
                index++;
            }
        }
        System.out.println(num);
    }
}
